package com.school.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.school.pojo.Grade;
import com.school.service.GradeService;
import com.school.util.Result;
import com.school.util.Tool;

@RequestMapping("/grade")
@RestController
public class GradeController implements Tool<Grade>{
	@Autowired
	private GradeService gradeService;

	@Override
	@RequestMapping("/findAll")
	public Result<Grade> findAll(int page, int pageSize, Grade t) {
		List<Grade> list= gradeService.findAll(page,pageSize,t);
		PageInfo<Grade> info=new PageInfo<Grade>(list);
		Result<Grade> result=new Result<>();
		result.setList(info.getList());
		result.setCount(info.getTotal());
		return result;
	}

	@Override
	@RequestMapping("/findbyId")
	public Result<Grade> findbyId(int grade_id) {
		Grade grade= gradeService.findbyId(grade_id);
		Result<Grade> result=new Result<Grade>();
		result.setData(grade);
		return result;
	}

	@Override
	@RequestMapping("/add")
	public int add(Grade t) {
		int row=gradeService.add(t);
		return row;
	}

	@Override
	@RequestMapping("/edit")
	public int edit(Grade t) {
		int row=gradeService.edit(t);
		return row;
	}

	@Override
	public int del(int id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	@RequestMapping("/delbatch")
	public int delbatch(int[] id) {
		
		return gradeService.delbatch(id);
	}
	
	
}
